<?php 
include('../Connections/KRAPPERCON.php');
$codart = '';
$codart = $_POST['t_codart'];
$field = $_POST['field'];
$sql = '';
$sql= "call sp_getArticulo('".$codart."');";
if (isset($_POST['t_codalm'])){
$codalm = $_POST['t_codalm'];
$sql= "call sp_getArticuloAlm('".$codart."','".$codalm."');";
}
if (isset($_POST['almc'])){
$codalm = $_POST['almc'];
$sql= "call sp_getArticuloStk('".$codart."','".$codalm."');";
}
//echo $sql;
$res = $mysqli->query($sql) or die($mysqli->error.__LINE__);

	if ($res){
	if ($row = $res->fetch_assoc()){
		if ($field == 'desc'){
			echo $row['ArticuloName'];
		}
		elseif ($field == 'venta'){
			echo "{code : '".$row['ArticuloID']."',desc : '".$row['ArticuloName']."', costo : '".$row['ArticuloCos']."' , precio : '".$row['ArticuloPre']."', stklib : ".$row['StockLib'].", dcto1 : ".$row['ArticuloDsc1'].", dcto2 : ".$row['ArticuloDsc2'].", um : '". $row['UnMedID'] ."'}";
		}
	}
	else {
			echo "{code : '',desc : 'NO EXISTE'}";
	}
	$res->close();
		
			$mysqli->check_result();
	}
?>